/**
 * Description:
 * Class Name:ToStringTest
 * Date:2022/1/27 9:28
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第6章_面向对象_下._6_2_处理对象;

class Apple{
    private String color;
    private double weight;
    public Apple(){}
    public Apple(String color, double weight){
        this.color = color;
        this.weight = weight;
    }
    // 省略color、weight的setter和getter方法
    // ...
    // 重写toString()方法，用于实现Apple对象的“自我描述”

    @Override
    public String toString() {
        return "Apple{" +
                "color='" + color + '\'' +
                ", weight=" + weight +
                '}';
    }
}

public class ToStringTest {
    public static void main(String[] args) {
        var a = new Apple("red", 5.66);
        System.out.println(a);
    }
}
